<%@page import="java.text.SimpleDateFormat"%>
<%@page pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set value="${ param.errorcode }" var="errorcode"></c:set>
<c:if test="${ not empty errorcode and errorcode eq 6 }">
	<script>alert("不可以删除当前用户");</script>
</c:if>
<c:set var="logined" value="${ false }" scope="page"></c:set>
<c:if test="${ empty sessionScope.username }">
	<c:set var="logined" value="${ true }" scope="page"></c:set>
</c:if>
<c:if test="${ empty cookie['username'].value }">
	<c:set var="logined" value="${ true }" scope="page"></c:set>
</c:if>
<%
	
%>
<c:if test="${ not pageScope.logined }">
	<c:redirect url="index.jsp">
		<c:param name="errorcode" value="4"></c:param>
	</c:redirect>
</c:if>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户信息</title>
<style>
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.table1 {
	border-left:1px #06F solid;
	border-top:1px #06F solid;
}
.td1 {
	border-right:1px #06F solid;
	border-bottom:1px #06F solid;
}
</style>
<script type="text/javascript">
	function getCurrentTime() {
		var d = new Date();
		document.getElementById("span1").innerHTML = d.toLocaleString(); 
	}
	setInterval("getCurrentTime()", 1000);
</script>
</head>
<body>
<c:if test=""></c:if>
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td class="td" style="font-size:50px; padding:15px 5px">公司logo</td>
    <td width="300">&nbsp;</td>
  </tr>
  <tr>
    <td>欢迎：<c:out value="${ sessionScope.username }"></c:out> <a href="exit.jsp">安全退出</a></td>
    <td>当前时间&nbsp;<span id="span1"></span></td>
  </tr>
  <tr>
  	<th colspan="2" style="font-size:20px;padding:15px 5px;background-color:#939">用户信息</th>
  </tr>
</table>
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0" class="table1">
  <tr>
    <td width="100" align="center" class="td1">用户名</td>
    <td align="center" class="td1">性别</td>
    <td align="center" class="td1">电话</td>
    <td width="200" align="center" class="td1">地址</td>
    <td align="center" class="td1">生日</td>
    <td align="center" class="td1">注册时间</td>
    <td align="center" class="td1">操作</td>
  </tr>
  
  <c:forEach items="${ requestScope.userlist }" var="ub">  
  <tr>
    <td width="130" align="center" class="td1">${ ub.username}</td>
    <td width="60" align="center" class="td1">${ ub.gender }</td>
    <td width="110" align="center" class="td1">${ ub.phone }</td>
    <td align="center" class="td1">${ ub.addr }</td>
    <td width="100" align="center" class="td1">${ ub.birth }</td>
    <td width="170" align="center" class="td1">${ ub.regDate }</td>
    <td width="80" align="center" class="td1"><a href="updateUser?username=${ ub.username }">修改</a> <a href="delete?username=${ ub.username }" onclick="return  confirm('确认删除')">删除</a></td>
  </tr>
  </c:forEach>
  
</table>
<table align="center">
	<tr>
		<c:if test="${ requestScope.headstate }">
		<td>首页</td>
		<td>上一页</td>
		</c:if>
		<c:if test="${  not requestScope.headstate }">
		<td><a href="listUsers?pageno=1">首页</a></td>
		<td><a href="listUsers?pageno=${ requestScope.pageno - 1 }">上一页</a></td>
		</c:if>
		
		<c:forEach begin="1" end="${ requestScope.totalpage }" var="i">
		<td><a href="listUsers?pageno=${ i }">${ i }</a></td>
		</c:forEach>
		
		<c:if test="${ requestScope.trailstate}">
		<td>下一页</td>
		<td>末页</td>
		</c:if>
		<c:if test="${ not requestScope.trailstate }">
		<td><a href="listUsers?pageno=${ requestScope.pageno + 1}">下一页</a></td>
		<td><a href="listUsers?pageno=${ requestScope.totalpage }">末页</a></td>
		</c:if>
	</tr>
</table>
</body>
</html>
